package com.lrkj.payfee.controller;

import com.lrkj.payfee.vo.TooReceiptVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.AdvicePayment;
import com.lrkj.payfee.service.IAdvicePaymentService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 付款单Controller
 *
 * @author yajun_ren
 * @date 2022-03-26
 */
@RestController
@RequestMapping("/payfee/advicePayment")
@Api(tags = "付款单")
public class AdvicePaymentController extends BaseController
{
    @Autowired
    private IAdvicePaymentService advicePaymentService;

    /**
     * 查询付款单列表
     */
    @ApiOperation(value = "查询付款单列表", notes = "查询付款单列表")
    @PreAuthorize("@ss.hasPermi('payfee:advicePayment:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdvicePayment advicePayment)
    {
        startPage();
        this.changeParameter(advicePayment.getParams());
        List<AdvicePayment> list = advicePaymentService.selectAdvicePaymentList(advicePayment);
        return getDataTable(list);
    }

    /**
     * 导出付款单列表
     */
	@ApiOperation(value = "导出付款单列表", notes = "导出付款单列表")
    @PreAuthorize("@ss.hasPermi('payfee:advicePayment:export')")
    @Log(title = "付款单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdvicePayment advicePayment)
    {
        List<AdvicePayment> list = advicePaymentService.selectAdvicePaymentList(advicePayment);
        ExcelUtil<AdvicePayment> util = new ExcelUtil<AdvicePayment>(AdvicePayment.class);
        return util.exportExcel(list, "付款单数据");
    }

    /**
     * 获取付款单详细信息
     */
	@ApiOperation(value = "获取付款单详细信息", notes = "获取付款单详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:advicePayment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(advicePaymentService.selectAdvicePaymentById(id));
    }

    /**
     * 新增付款单
     */
    @ApiOperation(value = "新增付款单", notes = "新增付款单")
    @PreAuthorize("@ss.hasPermi('payfee:advicePayment:add')")
    @Log(title = "付款单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdvicePayment advicePayment)
    {
        return toAjax(advicePaymentService.insertAdvicePayment(advicePayment));
    }

    /**
     * 修改付款单
     */
    @ApiOperation(value = "修改付款单", notes = "修改付款单")
    @PreAuthorize("@ss.hasPermi('payfee:advicePayment:edit')")
    @Log(title = "付款单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdvicePayment advicePayment)
    {
        return toAjax(advicePaymentService.updateAdvicePayment(advicePayment));
    }

    /**
     * 删除付款单
     */
    @ApiOperation(value = "删除付款单", notes = "删除付款单")
    @PreAuthorize("@ss.hasPermi('payfee:advicePayment:remove')")
    @Log(title = "付款单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(advicePaymentService.deleteAdvicePaymentByIds(ids));
    }

    /**
     * 查询已收款列表
     */
    @ApiOperation(value = "查询已收款列表", notes = "查询已收款列表")
    @PreAuthorize("@ss.hasPermi('payfee:advicePayment:tooReceiptlist')")
    @GetMapping("/tooReceiptlist")
    public TableDataInfo tooReceiptlist(TooReceiptVo tooReceiptVo)
    {
        startPage();
        this.changeParameter(tooReceiptVo.getParams());
        List<TooReceiptVo> list = advicePaymentService.tooReceiptlist(tooReceiptVo);
        return getDataTable(list);
    }


}
